Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getStyleObjectFromCSS to compute when cache miss #3024

Merged
merged 1 commit into from
Sep 15, 2022
Merged

getStyleObjectFromCSS to compute when cache miss #3024

merged 1 commit into from
Sep 15, 2022

Conversation

zurfyx
Copy link
Member

@zurfyx zurfyx commented Sep 15, 2022

We currently offer $getSelectionStyleValueForProperty and $getStyleObjectFromCSS as a way to directly access the value of the style properties they set on a TextNode.

Problem is it only works when these styles are applied via @lexical/selection, lexical style changes are never taken into account.

There's 3 ways to fix this:

  1. Have this function be more generic and less Node centric. The style records are always computed regardless of the source. (They weren't cleaned up anyway)
  2. Have some sort of listener that listens to TextNode modifications are updates the Map accordingly (difficult to use)
  3. Add to cache whenever you setValue: requires moving all style CSS to core (worth it?)

This PR implements 1 which is the one with the least friction and more user-friendly.

#3010

@vercel
Copy link

vercel bot commented Sep 15, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
lexical ✅ Ready (Inspect) Visit Preview Sep 15, 2022 at 1:23PM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview Sep 15, 2022 at 1:23PM (UTC)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants